import machine,time,_thread
from i2c_lcd import I2cLcd
from machine import Pin, I2C, ADC,PWM,UART
import network

uart=UART(1, baudrate=115200, tx=Pin(8), rx=Pin(9))
#串口#
uart.write('ready')

i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=100000)
lcd = I2cLcd(i2c, 0x27, 4, 20)  # 4行20列
lcd.putstr("READY!")

led = Pin(2, Pin.OUT)
led.value(1)
#板载启动指示灯#
hand_light=PWM(Pin(4))
hand_light.freq(1000)
hand_light.duty(0)
#前灯#
back_light=PWM(Pin(5))
back_light.freq(1000)
back_light.duty(0)
#后灯#
L_light=PWM(Pin(6))
L_light.freq(1000)
L_light.duty(0)
#左灯#
R_light=PWM(Pin(7))
R_light.freq(1000)
R_light.duty(0)
#右灯#
power=ADC(Pin(34))  
def power_thread():
    while True:
        power_value=power.read_u16()
        print(power_value)
        uart.write(str(power_value))

_thread.start_new_thread(power_thread,())
#油门控制
